using System.ComponentModel;

using DaprPlus.AspNetCore;
using DaprPlus.Builder;
using DaprPlus.Extensions;

using Liuliu.Fsb.ApiGateway.Startups;

using Shares.Infrastructure.AspNetCore;


namespace Liuliu.Fsb.ApiGateway
{
    [Description("ApiGateway启动模块")]
    [DependsOnModules(
        typeof(DaprAspNetCoreModule)
        , typeof(OpenApiModule)
        )]
    public class StartupModule : AspModuleBase
    {
        /// <summary>应用AspNetCore的服务业务</summary>
        /// <param name="app">Web应用程序</param>
        public override async Task UseModule(WebApplication app)
        {
            if (app.Environment.IsDevelopment())
            {
                app.UseSwaggerUI(opts =>
                {
                    opts.SwaggerEndpoint("/identity/openapi/v1.json", "identity api");
                    opts.SwaggerEndpoint("/todos/openapi/v1.json", "todos api");
                });
            }

            app.UseHttpsRedirection();

            await base.UseModule(app);
        }
    }
}
